﻿// JScript 文件

Ext.onReady(function () {
    // 使用表单提示
    Ext.QuickTips.init();
    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var sm = new Ext.grid.CheckboxSelectionModel();

    var cm = new Ext.grid.ColumnModel([
	    new Ext.grid.RowNumberer(),
		sm,
		{ header: '类型', width: 80, align: 'center', dataIndex: 'logType',renderer:function(v){if(v==0) return "信息"; if(v==1) return "错误";} },
		{ header: '信息', width: 300, align: 'left', dataIndex: 'logDesNO',renderer:function(v){
		                                                                                            if(v==0) {
		                                                                                                return "测试";
		                                                                                            } else if(v==1) {
		                                                                                                return "用户登陆";
		                                                                                            } else if(v==2) {
		                                                                                                return "";
		                                                                                            }
		                                                                                         }
		},
		{ header: '时间', width: 120, align: 'center', dataIndex: 'logTime' },
        { header: 'IP', width: 100, align: 'center', dataIndex: 'logIP' },
        { header: '页面', width: 90, align: 'center', dataIndex: 'logPage' },
        { header: '用户名', width: 140, align: 'center', dataIndex: 'userName' },
        { header: '真实名', width:100, align:'center',dataIndex:'mobilePhone'} 
        

	]);

    cm.defaultSortable = true;

    var ds = new Ext.data.GroupingStore({
        proxy: new Ext.data.HttpProxy({
            url: 'ashx/SysLog_GetByPage.ashx'
        }),
        reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
        },
		[{ name: 'id', mapping: 'logId', type: 'string' }, 
		 { name: 'logType', type: 'string' },
         { name: 'logDesNO', type: 'string' },
		 { name: 'logTime', type: 'string' },
		 { name: 'logPage', type: 'string' },
         { name: 'logIP', type: 'string' },
         { name: 'userName', type: 'string' },
         { name: 'realName', type: 'string' } 
		])
    });

    var paging = new Ext.PagingToolbar({
        pageSize: 20,
        store: ds,
        displayInfo: true,
        displayMsg: '显示第{0}条到{1}条记录，一共{2}条',
        items:
		["-", " "   
		],
        emptyMsg: "查询记录为空!"
    });

    var grid = new Ext.grid.EditorGridPanel({
        renderTo: 'grid-div',
        cm: cm,
        ds: ds,
        sm: sm, 
        bbar: paging,
        height: 500,
        border: true,
        bodyStyle: 'width:1020px',
        stripeRows: true,
        title: '系统日志'
    });

    ds.load({ params: { start: 0, limit: 20} });





 


});